package cn.hwadee.muying.enums;

import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;

/**
 * Created by Mankind on 2018/8/3.
 */
public enum Education implements IEnum {
    SECONDARY_SCHOOL(1,"中专"),
    COLLEGE_SCHOOL(2,"大专"),
    MIDDLE_SCHOOL(3,"初中"),
    HIGH_SCHOOL(4,"高中"),
    BACHELOR_DEGREE(5,"本科"),
    MASTER_DEGREE(6,"硕士"),
    DOCTOR_DEGREE(7,"博士");

    private int value;
    private String desc;
    Education(final int value, final String desc){
        this.value=value;
        this.desc=desc;
    }

    @Override
    public Serializable getValue() {
        return this.value;
    }

    @JsonValue
    public String getDesc(){
        return this.desc;
    }

    public static Education getById(int id) {
        Education[] types = Education.values();
        for(Education type : types){
            if(type.value == id){
                return type;
            }
        }
        return null;
    }

    public static Education getByDesc(String desc) {
        Education[] educations = Education.values();
        for(Education education : educations){
            if(education.desc.equals(desc)){
                return education;
            }
        }
        return null;
    }


}
